home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / JDialog.java < prev    next >
Text File  |  1998-06-30  |  31KB  |  964 lines

  1. /*
  2.  * @(#)JDialog.java    1.30 98/04/03
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.beans.PropertyChangeListener;
  25. import java.util.Locale;
  26. import java.util.Vector;
  27. import java.io.Serializable;
  28. import com.sun.java.accessibility.*;
  29. import java.applet.Applet;
  30.  
  31. /** 
  32.  * The main class for creating a dialog window. You can use this class
  33.  * to create a custom dialog, or invoke the many static methods
  34.  * in JOptionPane to create a variety of standard dialogs.
  35.  *
  36.  * The JDialog component contains a JRootPane as it's only 
  37.  * child.
  38.  * The <code>contentPane</code> should be the parent of any children of 
  39.  * the JDialog. From the older <code>java.awt.Window</code> object you 
  40.  * would normally do something like this:
  41.  * <PRE>
  42.  *       dialog.add(child);
  43.  * </PRE>
  44.  * Using JDialog the proper semantic is:
  45.  * <PRE>
  46.  *       dialog.getContentPane().add(child);
  47.  * </PRE>
  48.  * The same priniciple holds true for setting layout managers, removing 
  49.  * components, listing children, etc. All these methods should normally 
  50.  * be sent to the <code>contentPane</code> instead of to the JDialog.
  51.  * The <code>contentPane</code> is always non-null. Attempting to set it 
  52.  * to null generates an exception. The default <code>contentPane</code> 
  53.  * has a BorderLayout manager set on it. 
  54.  * <p>
  55.  * Please see the JRootPane documentation for a complete 
  56.  * description of the <code>contentPane</code>, <code>glassPane</code>, 
  57.  * and <code>layeredPane</code> components.
  58.  * <p>
  59.  * NOTE: For 1.1, Modal dialogs are currently constrained to only allow
  60.  * lightweight popup menus (JPopupMenu, JComboBox, JMenuBar) because
  61.  * of window ownership limitations in AWT1.1.   This creates the further
  62.  * limitation of not being able to mix Swing popup components with
  63.  * AWT heavyweight components in a modal dialog since the heavyweight
  64.  * components would always overlap the lightweights, potentially
  65.  * obscuring the popup menu.
  66.  * (A heavyweight component uses a native-platform component (peer)
  67.  * component for its implementation -- AWT components are heavyweight
  68.  * components.)
  69.  * <p>
  70.  * For the keyboard keys used by this component in the standard Look and
  71.  * Feel (L&F) renditions, see the
  72.  * <a href="doc-files/Key-Index.html#JDialog">JDialog</a> key assignments.
  73.  * <p>
  74.  * Warning: serialized objects of this class will not be compatible with
  75.  * future swing releases.  The current serialization support is appropriate 
  76.  * for short term storage or RMI between Swing1.0 applications.  It will
  77.  * not be possible to load serialized Swing1.0 objects with future releases
  78.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  79.  * baseline for the serialized form of Swing objects.
  80.  *
  81.  * @see JOptionPane
  82.  * @see JRootPane
  83.  *
  84.  * @beaninfo
  85.  *      attribute: isContainer true
  86.  *      attribute: containerDelegate getContentPane
  87.  *    description: A toplevel window for creating dialog boxes.
  88.  *
  89.  * @version 1.30 04/03/98
  90.  * @author David Kloba
  91.  * @author James Gosling
  92.  * @author Scott Violet
  93.  */
  94. public class JDialog extends Dialog implements WindowConstants, Accessible, RootPaneContainer 
  95. {
  96.     private int defaultCloseOperation = HIDE_ON_CLOSE;
  97.     
  98.     /**
  99.      * @see #getRootPane
  100.      * @see #setRootPane
  101.      */
  102.     protected JRootPane rootPane;
  103.  
  104.     /**
  105.      * @see #isRootPaneCheckingEnabled
  106.      * @see #setRootPaneCheckingEnabled
  107.      */
  108.     protected boolean rootPaneCheckingEnabled = false;
  109.  
  110.  
  111.     /**
  112.      * Creates a non-modal dialog without a title and without
  113.      * a specified Frame owner.  A shared, hidden frame will be
  114.      * set as the owner of the Dialog.
  115.      */
  116.     public JDialog() {
  117.         this(null, false);
  118.     }
  119.  
  120.     /**
  121.      * Creates a non-modal dialog without a title with the
  122.      * specifed Frame as its owner.
  123.      *
  124.      * @param owner the Frame from which the dialog is displayed
  125.      */
  126.     public JDialog(Frame owner) {
  127.         this(owner, false);
  128.     }
  129.  
  130.     /**
  131.      * Creates a modal or non-modal dialog without a title and
  132.      * with the specified owner frame.
  133.      * <p>
  134.      * NOTE: Modal dialogs cannot have heavyweight components in them.
  135.      *
  136.      * @param owner the Frame from which the dialog is displayed
  137.      * @param modal  true for a modal dialog, false for one that allows
  138.      *               others windows to be active at the same time
  139.      */
  140.     public JDialog(Frame owner, boolean modal) {
  141.         this(owner, null, modal);
  142.     }
  143.  
  144.     /**
  145.      * Creates a non-modal dialog with the specified title and
  146.      * with the specified owner frame.
  147.      *
  148.      * @param owner the Frame from which the dialog is displayed
  149.      * @param title  the String to display in the dialog's title bar
  150.      */
  151.     public JDialog(Frame owner, String title) {
  152.         this(owner, title, false);     
  153.     }
  154.  
  155.     /**
  156.      * Creates a modal or non-modal dialog with the specified title 
  157.      * and the specified owner frame.
  158.      * <p>
  159.      * NOTE: Any popup components (JComboBox, JPopupMenu, JMenuBar)
  160.      * created within a modal dialog will be forced to be lightweight.
  161.      *
  162.      * @param owner the frame from which the dialog is displayed
  163.      * @param title  the String to display in the dialog's title bar
  164.      * @param modal  true for a modal dialog, false for one that allows
  165.      *               others windows to be active at the same time
  166.      */
  167.     public JDialog(Frame owner, String title, boolean modal) {
  168.         super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner, 
  169.               title, modal);
  170.         dialogInit();
  171.     }
  172.  
  173.     /** Called by the constructors to init the JDialog properly. */
  174.     protected void dialogInit() {
  175.         enableEvents(AWTEvent.WINDOW_EVENT_MASK);
  176.         setRootPane(createRootPane());
  177.         setRootPaneCheckingEnabled(true);
  178.     }
  179.  
  180.     /** Called by the constructor methods to create the default rootPane. */
  181.     protected JRootPane createRootPane() {
  182.         return new JRootPane();
  183.     }
  184.  
  185.     /**
  186.      * Handles window events depending on the state of the
  187.      * <code>defaultCloseOperation</code> property.
  188.      *
  189.      * @see #setDefaultCloseOperation
  190.      */
  191.     protected void processWindowEvent(WindowEvent e) {
  192.         super.processWindowEvent(e);
  193.  
  194.         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
  195.             switch(defaultCloseOperation) {
  196.               case HIDE_ON_CLOSE:
  197.                  setVisible(false);
  198.                  break;
  199.               case DISPOSE_ON_CLOSE:
  200.                  setVisible(false);
  201.                  dispose();
  202.                  break;
  203.               case DO_NOTHING_ON_CLOSE:
  204.                  default: 
  205.                  break;
  206.             }
  207.         }
  208.     }
  209.  
  210.  
  211.     /**
  212.      * Sets the operation which will happen by default when
  213.      * the user initiates a "close" on this dialog.
  214.      * The possible choices are:
  215.      * <ul>
  216.      * <li>DO_NOTHING_ON_CLOSE - do not do anything - require the
  217.      * program to handle the operation in the windowClosing
  218.      * method of a registered WindowListener object.
  219.      * <li>HIDE_ON_CLOSE - automatically hide the dialog after
  220.      * invoking any registered WindowListener objects
  221.      * <li>DISPOSE_ON_CLOSE - automatically hide and dispose the 
  222.      * dialog after invoking any registered WindowListener objects
  223.      * </ul>
  224.      * <p>
  225.      * The value is set to HIDE_ON_CLOSE by default.
  226.      * @see #addWindowListener
  227.      * @see #getDefaultCloseOperation
  228.      *
  229.      * @beaninfo
  230.      *   preferred: true
  231.      * description: The dialog's default close operation.
  232.      */
  233.     public void setDefaultCloseOperation(int operation) {
  234.         this.defaultCloseOperation = operation;
  235.     }
  236.  
  237.    /**
  238.     * Returns the operation which occurs when the user
  239.     * initiates a "close" on this dialog.
  240.     *
  241.     * @return an int indicating the window-close operation
  242.     * @see #setDefaultCloseOperation
  243.     */
  244.     public int getDefaultCloseOperation() {
  245.         return defaultCloseOperation;
  246.     }
  247.  
  248.  
  249.     /** 
  250.      * Just calls <code>paint(g)</code>.  This method was overridden to 
  251.      * prevent an unneccessary call to clear the background.
  252.      */
  253.     public void update(Graphics g) {
  254.         paint(g);
  255.     }
  256.  
  257.    /**
  258.     * Sets the menubar for this dialog.
  259.     * @param menubar the menubar being placed in the dialog
  260.     *
  261.     * @see #getJMenuBar
  262.     *
  263.     * @beaninfo
  264.     *      hidden: true
  265.     * description: The menubar for accessing pulldown menus from this dialog.
  266.     */
  267.     public void setJMenuBar(JMenuBar menu) {
  268.         getRootPane().setMenuBar(menu);
  269.     }
  270.  
  271.    /**
  272.     * Returns the menubar set on this dialog.
  273.     *
  274.     * @see #setJMenuBar
  275.     */
  276.     public JMenuBar getJMenuBar() { 
  277.         return getRootPane().getMenuBar(); 
  278.     }
  279.  
  280.  
  281.     /**
  282.      * @return true if add and setLayout should be checked
  283.      * @see #addImpl
  284.      * @see #setLayout
  285.      * @see #setRootPaneCheckingEnabled
  286.      */
  287.     protected boolean isRootPaneCheckingEnabled() {
  288.         return rootPaneCheckingEnabled;
  289.     }
  290.  
  291.  
  292.     /**
  293.      * If true then calls to add() and setLayout() will cause an exception
  294.      * to be thrown.  
  295.      *
  296.      * @see #addImpl
  297.      * @see #setLayout
  298.      * @see #isRootPaneCheckingEnabled
  299.      * @beaninfo
  300.      *   hidden: true
  301.      * description: Whether the add and setLayout methods throw exceptions when invoked.
  302.      */
  303.     protected void setRootPaneCheckingEnabled(boolean enabled) {
  304.         rootPaneCheckingEnabled = enabled;
  305.     }
  306.  
  307.     /**
  308.      * Create an runtime exception with a message like:
  309.      * <pre>
  310.      * "Do not use JDialog.add() use JDialog.getContentPane().add() instead"
  311.      * </pre>
  312.      */
  313.     private Error createRootPaneException(String op) {
  314.         String type = getClass().getName();
  315.         return new Error(
  316.             "Do not use " + type + "." + op + "() use " 
  317.                           + type + ".getContentPane()." + op + "() instead");
  318.     }
  319.  
  320.  
  321.     /**
  322.      * By default, children may not be added directly to a this component,
  323.      * they must be added to its contentPane instead.  For example:
  324.      * <pre>
  325.      * thisComponent.getContentPane().add(child)
  326.      * </pre>
  327.      * An attempt to add to directly to this component will cause an
  328.      * runtime exception to be thrown.  Subclasses can disable this
  329.      * behavior.
  330.      * 
  331.      * @see #setRootPaneCheckingEnabled
  332.      * @exception Error if called with rootPaneChecking true
  333.      */
  334.     protected void addImpl(Component comp, Object constraints, int index) 
  335.     {
  336.         if(isRootPaneCheckingEnabled()) {
  337.             throw createRootPaneException("add");
  338.         }
  339.         else {
  340.             super.addImpl(comp, constraints, index);
  341.         }
  342.     }
  343.  
  344.  
  345.     /**
  346.      * By default the layout of this component may not be set,
  347.      * the layout of its contentPane should be set instead.  
  348.      * For example:
  349.      * <pre>
  350.      * thisComponent.getContentPane().setLayout(new BorderLayout())
  351.      * </pre>
  352.      * An attempt to set the layout of this component will cause an
  353.      * runtime exception to be thrown.  Subclasses can disable this
  354.      * behavior.
  355.      * 
  356.      * @see #setRootPaneCheckingEnabled
  357.      * @exception Error if called with rootPaneChecking true
  358.      */
  359.     public void setLayout(LayoutManager manager) {
  360.         if(isRootPaneCheckingEnabled()) {
  361.             throw createRootPaneException("setLayout");
  362.         }
  363.         else {
  364.             super.setLayout(manager);
  365.         }
  366.     }
  367.  
  368.  
  369.     /**
  370.      * Returns the rootPane object for this dialog.
  371.      *
  372.      * @see #setRootPane
  373.      * @see RootPaneContainer#getRootPane
  374.      */
  375.     public JRootPane getRootPane() { 
  376.         return rootPane; 
  377.     }
  378.  
  379.  
  380.     /**
  381.      * Sets the rootPane property.  This method is called by the constructor.
  382.      * @param root the rootPane object for this dialog
  383.      *
  384.      * @see #getRootPane
  385.      *
  386.      * @beaninfo
  387.      *   hidden: true
  388.      * description: the RootPane object for this dialog.
  389.      */
  390.     protected void setRootPane(JRootPane root) {
  391.         if(rootPane != null) {
  392.             remove(rootPane);
  393.         }
  394.         rootPane = root;
  395.         if(rootPane != null) {
  396.             boolean checkingEnabled = isRootPaneCheckingEnabled();
  397.             try {
  398.                 setRootPaneCheckingEnabled(false);
  399.                 add(rootPane, BorderLayout.CENTER);
  400.             }
  401.             finally {
  402.                 setRootPaneCheckingEnabled(checkingEnabled);
  403.             }
  404.         }
  405.     }
  406.  
  407.  
  408.     /**
  409.      * Returns the contentPane object for this dialog.
  410.      *
  411.      * @see #setContentPane
  412.      * @see RootPaneContainer#getContentPane
  413.      */
  414.     public Container getContentPane() { 
  415.         return getRootPane().getContentPane(); 
  416.     }
  417.  
  418.  
  419.    /**
  420.      * Sets the contentPane property.  This method is called by the constructor.
  421.      * @param contentPane the contentPane object for this dialog
  422.      *
  423.      * @exception java.awt.IllegalComponentStateException (a runtime
  424.      *            exception) if the content pane parameter is null
  425.      * @see #getContentPane
  426.      * @see RootPaneContainer#setContentPane
  427.      *
  428.      * @beaninfo
  429.      *     hidden: true
  430.      *     description: The client area of the dialog where child 
  431.      *                  components are normally inserted.
  432.      */
  433.     public void setContentPane(Container contentPane) {
  434.         getRootPane().setContentPane(contentPane);
  435.     }
  436.  
  437.     /**
  438.      * Returns the layeredPane object for this dialog.
  439.      *
  440.      * @see #setLayeredPane
  441.      * @see RootPaneContainer#getLayeredPane
  442.      */
  443.     public JLayeredPane getLayeredPane() { 
  444.         return getRootPane().getLayeredPane(); 
  445.     }
  446.  
  447.     /**
  448.      * Sets the layeredPane property.  This method is called by the constructor.
  449.      * @param layeredPane the layeredPane object for this dialog
  450.      *
  451.      * @exception java.awt.IllegalComponentStateException (a runtime
  452.      *            exception) if the layered pane parameter is null
  453.      * @see #getLayeredPane
  454.      * @see RootPaneContainer#setLayeredPane
  455.      *
  456.      * @beaninfo
  457.      *     hidden: true
  458.      *     description: The pane which holds the various dialog layers.
  459.      */
  460.     public void setLayeredPane(JLayeredPane layeredPane) {
  461.         getRootPane().setLayeredPane(layeredPane);
  462.     }
  463.  
  464.     /**
  465.      * Returns the glassPane object for this dialog.
  466.      *
  467.      * @see #setGlassPane
  468.      * @see RootPaneContainer#getGlassPane
  469.      */
  470.     public Component getGlassPane() { 
  471.         return getRootPane().getGlassPane(); 
  472.     }
  473.  
  474.     /**
  475.      * Sets the glassPane property. 
  476.      * This method is called by the constructor.
  477.      * @param glassPane the glassPane object for this dialog
  478.      * @see #getGlassPane
  479.      * @see RootPaneContainer#setGlassPane
  480.      *
  481.      * @beaninfo
  482.      *     hidden: true
  483.      *     description: A transparent pane used for menu rendering.
  484.      */
  485.     public void setGlassPane(Component glassPane) {
  486.         getRootPane().setGlassPane(glassPane);
  487.     }
  488.  
  489.  
  490.     /**
  491.      * Sets the location of the dialog relative to the specified
  492.      * component. If the component is not currently showing, the 
  493.      * dialog is centered on the screen.
  494.      *
  495.      * @param c  the component in relation to which the dialog's location
  496.      *           is determined
  497.      */
  498.     public void setLocationRelativeTo(Component c) {
  499.         Container root=null;
  500.  
  501.         if (c != null) {
  502.             if (c instanceof Window || c instanceof Applet) {
  503.                root = (Container)c;
  504.             } else {
  505.                 Container parent;
  506.                 for(parent = c.getParent() ; parent != null ; parent = parent.getParent()) {
  507.                     if (parent instanceof Window || parent instanceof Applet) {
  508.                         root = parent;
  509.                         break;
  510.                     }
  511.                 }
  512.             }
  513.         }
  514.  
  515.         if((c != null && !c.isShowing()) || root == null ||
  516.            !root.isShowing()) {
  517.             Dimension         paneSize = getSize();
  518.             Dimension         screenSize = getToolkit().getScreenSize();
  519.  
  520.             setLocation((screenSize.width - paneSize.width) / 2,
  521.                         (screenSize.height - paneSize.height) / 2);
  522.         } else {
  523.             Dimension           invokerSize = c.getSize();
  524.             Point               invokerScreenLocation = c.getLocationOnScreen();
  525.             Rectangle           dialogBounds = getBounds();
  526.             int                 dx = invokerScreenLocation.x+((invokerSize.width-dialogBounds.width)>>1);
  527.             int                 dy = invokerScreenLocation.y+((invokerSize.height - dialogBounds.height)>>1);
  528.             Dimension           ss = getToolkit().getScreenSize();
  529.  
  530.             if (dy+dialogBounds.height>ss.height) {
  531.                 dy = ss.height-dialogBounds.height;
  532.                 dx = invokerScreenLocation.x<(ss.width>>1) ? invokerScreenLocation.x+invokerSize.width :
  533.                     invokerScreenLocation.x-dialogBounds.width;
  534.             }
  535.             if (dx+dialogBounds.width>ss.width) dx = ss.width-dialogBounds.width;
  536.             if (dx<0) dx = 0;
  537.             if (dy<0) dy = 0;
  538.             setLocation(dx, dy);
  539.         }
  540.     }
  541.  
  542.  
  543. /////////////////
  544. // Accessibility support
  545. ////////////////
  546.  
  547.     protected AccessibleContext accessibleContext = null;
  548.  
  549.     /**
  550.      * Get the AccessibleContext associated with this JDialog
  551.      *
  552.      * @return the AccessibleContext of this JDialog
  553.      */
  554.     public AccessibleContext getAccessibleContext() {
  555.         if (accessibleContext == null) {
  556.             accessibleContext = new AccessibleJDialog();
  557.         }
  558.         return accessibleContext;
  559.     }
  560.  
  561.     /**
  562.      * The class used to obtain the AccessibleRole for this object.
  563.      */
  564.     protected class AccessibleJDialog extends AccessibleContext 
  565.         implements Serializable, AccessibleComponent {
  566.  
  567.         
  568.         // AccessibleContext methods
  569.         //
  570.         /**
  571.          * Get the accessible name of this object.  
  572.          *
  573.          * @return the localized name of the object -- can be null if this 
  574.          * object does not have a name
  575.          */
  576.         public String getAccessibleName() {
  577.             if (accessibleName != null) {
  578.                 return accessibleName;
  579.             } else {
  580.                 if (getTitle() == null) {
  581.                     return super.getAccessibleName();
  582.                 } else {
  583.                     return getTitle();
  584.                 }
  585.             }
  586.         }
  587.  
  588.         /**
  589.          * Get the role of this object.
  590.          *
  591.          * @return an instance of AccessibleRole describing the role of the 
  592.          * object
  593.          * @see AccessibleRole
  594.          */
  595.         public AccessibleRole getAccessibleRole() {
  596.             return AccessibleRole.DIALOG;
  597.         }
  598.  
  599.         /**
  600.          * Get the state of this object.
  601.          *
  602.          * @return an instance of AccessibleStateSet containing the current 
  603.          * state set of the object
  604.          * @see AccessibleState
  605.          */
  606.         public AccessibleStateSet getAccessibleStateSet() {
  607.             AccessibleStateSet states = SwingUtilities.getAccessibleStateSet(JDialog.this);
  608.             if (isResizable()) {
  609.                 states.add(AccessibleState.RESIZABLE);
  610.             }
  611.             if (getFocusOwner() != null) {
  612.                 states.add(AccessibleState.ACTIVE);
  613.             }
  614.             if (isModal()) {
  615.                 states.add(AccessibleState.MODAL);
  616.             }
  617.             return states;
  618.         }
  619.  
  620.         /**
  621.          * Get the Accessible parent of this object.  If the parent of this
  622.          * object implements Accessible, this method should simply return
  623.          * getParent().
  624.          *
  625.          * @return the Accessible parent of this object -- can be null if this
  626.          * object does not have an Accessible parent
  627.          */
  628.         public Accessible getAccessibleParent() {
  629.             Container parent = getParent();
  630.             if (parent instanceof Accessible) {
  631.                 return (Accessible) parent;
  632.             } else {
  633.                 return null;
  634.             }
  635.         }
  636.  
  637.         /**
  638.          * Get the index of this object in its accessible parent. 
  639.          *
  640.          * @return the index of this object in its parent; -1 if this 
  641.          * object does not have an accessible parent.
  642.          * @see #getAccessibleParent
  643.          */
  644.         public int getAccessibleIndexInParent() {
  645.             return SwingUtilities.getAccessibleIndexInParent(JDialog.this);
  646.         }
  647.  
  648.         /**
  649.          * Returns the number of accessible children in the object.  If all
  650.          * of the children of this object implement Accessible, than this
  651.          * method should return the number of children of this object.
  652.          *
  653.          * @return the number of accessible children in the object.
  654.          */
  655.         public int getAccessibleChildrenCount() {
  656.             return SwingUtilities.getAccessibleChildrenCount(JDialog.this);
  657.         }
  658.  
  659.         /**
  660.          * Return the nth Accessible child of the object.  
  661.          *
  662.          * @param i zero-based index of child
  663.          * @return the nth Accessible child of the object
  664.          */
  665.         public Accessible getAccessibleChild(int i) {
  666.             return SwingUtilities.getAccessibleChild(JDialog.this,i);
  667.         }
  668.  
  669.         /**
  670.          * Return the locale of this object.
  671.          *
  672.          * @return the locale of this object
  673.          */
  674.         public Locale getLocale() {
  675.             return JDialog.this.getLocale();
  676.         }
  677.  
  678.         /**
  679.          * Get the AccessibleComponent associated with this object if one
  680.          * exists.  Otherwise return null.
  681.          */
  682.         public AccessibleComponent getAccessibleComponent() {
  683.             return this;
  684.         }
  685.  
  686.  
  687.         // AccessibleComponent methods
  688.         //
  689.         /**
  690.          * Get the background color of this object.
  691.          *
  692.          * @return the background color, if supported, of the object; 
  693.          * otherwise, null
  694.          */
  695.         public Color getBackground() {
  696.             return JDialog.this.getBackground();
  697.         }
  698.  
  699.         /**
  700.          * Set the background color of this object.
  701.          *
  702.          * @param c the new Color for the background
  703.          */
  704.         public void setBackground(Color c) {
  705.             JDialog.this.setBackground(c);
  706.         }
  707.  
  708.         /**
  709.          * Get the foreground color of this object.
  710.          *
  711.          * @return the foreground color, if supported, of the object; 
  712.          * otherwise, null
  713.          */
  714.         public Color getForeground() {
  715.             return JDialog.this.getForeground();
  716.         }
  717.  
  718.         /**
  719.          * Set the foreground color of this object.
  720.          *
  721.          * @param c the new Color for the foreground
  722.          */
  723.         public void setForeground(Color c) {
  724.             JDialog.this.setForeground(c);
  725.         }
  726.  
  727.         /**
  728.          * Get the Cursor of this object.
  729.          *
  730.          * @return the Cursor, if supported, of the object; otherwise, null
  731.          */
  732.         public Cursor getCursor() {
  733.             return JDialog.this.getCursor();
  734.         }
  735.  
  736.         /**
  737.          * Set the Cursor of this object.
  738.          *
  739.          * @param c the new Cursor for the object
  740.          */
  741.         public void setCursor(Cursor cursor) {
  742.             JDialog.this.setCursor(cursor);
  743.         }
  744.  
  745.         /**
  746.          * Get the Font of this object.
  747.          *
  748.          * @return the Font,if supported, for the object; otherwise, null
  749.          */
  750.         public Font getFont() {
  751.             return JDialog.this.getFont();
  752.         }
  753.  
  754.         /**
  755.          * Set the Font of this object.
  756.          *
  757.          * @param f the new Font for the object
  758.          */
  759.         public void setFont(Font f) {
  760.             JDialog.this.setFont(f);
  761.         }
  762.  
  763.         /**
  764.          * Get the FontMetrics of this object.
  765.          *
  766.          * @param f the Font
  767.          * @return the FontMetrics, if supported, the object; otherwise, null
  768.          * @see getFont
  769.          */
  770.         public FontMetrics getFontMetrics(Font f) {
  771.             return JDialog.this.getFontMetrics(f);
  772.         }
  773.  
  774.         /**
  775.          * Determine if the object is enabled.
  776.          *
  777.          * @return true if object is enabled; otherwise, false
  778.          */
  779.         public boolean isEnabled() {
  780.             return JDialog.this.isEnabled();
  781.         }
  782.  
  783.         /**
  784.          * Set the enabled state of the object.
  785.          *
  786.          * @param b if true, enables this object; otherwise, disables it 
  787.          */
  788.         public void setEnabled(boolean b) {
  789.             JDialog.this.setEnabled(b);
  790.         }
  791.         
  792.         /**
  793.          * Determine if the object is visible.  Note: this means that the
  794.          * object intends to be visible; however, it may not in fact be
  795.          * showing on the screen because one of the objects that this object
  796.          * is contained by is not visible.  To determine if an object is
  797.          * showing on the screen, use isShowing().
  798.          *
  799.          * @return true if object is visible; otherwise, false
  800.          */
  801.         public boolean isVisible() {
  802.             return JDialog.this.isVisible();
  803.         }
  804.  
  805.         /**
  806.          * Set the visible state of the object.
  807.          *
  808.          * @param b if true, shows this object; otherwise, hides it 
  809.          */
  810.         public void setVisible(boolean b) {
  811.             JDialog.this.setVisible(b);
  812.         }
  813.  
  814.         /**
  815.          * Determine if the object is showing. This is determined by checking
  816.          * the visibility of the object and ancestors of the object.  Note: 
  817.          * this will return true even if the object is obscured by another 
  818.          * (for example, it happens to be underneath a menu that was pulled 
  819.          * down).
  820.          *
  821.          * @return true if object is showing; otherwise, false
  822.          */
  823.         public boolean isShowing() {
  824.             return JDialog.this.isShowing();
  825.         }
  826.  
  827.         /** 
  828.          * Checks whether the specified point is within this object's bounds,
  829.          * where the point's x and y coordinates are defined to be relative to 
  830.          * the coordinate system of the object. 
  831.          *
  832.          * @param p the Point relative to the coordinate system of the object
  833.          * @return true if object contains Point; otherwise false
  834.          */
  835.         public boolean contains(Point p) {
  836.             return JDialog.this.contains(p);
  837.         }
  838.     
  839.         /** 
  840.          * Returns the location of the object on the screen.
  841.          *
  842.          * @return location of object on screen -- can be null if this object
  843.          * is not on the screen
  844.          */
  845.         public Point getLocationOnScreen() {
  846.             return JDialog.this.getLocationOnScreen();
  847.         }
  848.  
  849.         /** 
  850.          * Gets the location of the object relative to the parent in the form 
  851.          * of a point specifying the object's top-left corner in the screen's 
  852.          * coordinate space.
  853.          *
  854.          * @return An instance of Point representing the top-left corner of 
  855.          * the objects's bounds in the coordinate space of the screen; null if
  856.          * this object or its parent are not on the screen
  857.          */
  858.         public Point getLocation() {
  859.             return JDialog.this.getLocation();
  860.         }
  861.  
  862.         /** 
  863.          * Sets the location of the object relative to the parent.
  864.          */
  865.         public void setLocation(Point p) {
  866.             JDialog.this.setLocation(p);
  867.         }
  868.  
  869.         /** 
  870.          * Gets the bounds of this object in the form of a Rectangle object. 
  871.          * The bounds specify this object's width, height, and location
  872.          * relative to its parent. 
  873.          *
  874.          * @return A rectangle indicating this component's bounds; null if 
  875.          * this object is not on the screen.
  876.          */
  877.         public Rectangle getBounds() {
  878.             return JDialog.this.getBounds();
  879.         }
  880.  
  881.         /** 
  882.          * Sets the bounds of this object in the form of a Rectangle object. 
  883.          * The bounds specify this object's width, height, and location
  884.          * relative to its parent.
  885.          *      
  886.          * @param A rectangle indicating this component's bounds
  887.          */
  888.         public void setBounds(Rectangle r) {
  889.             JDialog.this.setBounds(r);
  890.         }
  891.  
  892.         /** 
  893.          * Returns the size of this object in the form of a Dimension object. 
  894.          * The height field of the Dimension object contains this objects's
  895.          * height, and the width field of the Dimension object contains this 
  896.          * object's width. 
  897.          *
  898.          * @return A Dimension object that indicates the size of this 
  899.          * component; null if this object is not on the screen
  900.          */
  901.         public Dimension getSize() {
  902.             return JDialog.this.getSize();
  903.         }
  904.  
  905.         /** 
  906.          * Resizes this object so that it has width width and height. 
  907.          *      
  908.          * @param d - The dimension specifying the new size of the object. 
  909.          */
  910.         public void setSize(Dimension d) {
  911.             JDialog.this.setSize(d);
  912.         }
  913.  
  914.         /**
  915.          * Returns the Accessible child, if one exists, contained at the local
  916.          * coordinate Point.
  917.          *
  918.          * @param p The point defining the top-left corner of the Accessible, 
  919.          * given in the coordinate space of the object's parent. 
  920.          * @return the Accessible, if it exists, at the specified location; 
  921.          * else null
  922.          */
  923.         public Accessible getAccessibleAt(Point p) {
  924.             return SwingUtilities.getAccessibleAt(JDialog.this,p);
  925.         }
  926.  
  927.         /**
  928.          * Returns whether this object can accept focus or not.
  929.          *
  930.          * @return true if object can accept focus; otherwise false
  931.          */
  932.         public boolean isFocusTraversable() {
  933.             return JDialog.this.isFocusTraversable();
  934.         }
  935.  
  936.         /**
  937.          * Requests focus for this object.
  938.          */
  939.         public void requestFocus() {
  940.             JDialog.this.requestFocus();
  941.         }
  942.  
  943.         /**
  944.          * Adds the specified focus listener to receive focus events from this 
  945.          * component. 
  946.          *
  947.          * @param l the focus listener
  948.          */
  949.         public void addFocusListener(FocusListener l) {
  950.             JDialog.this.addFocusListener(l);
  951.         }
  952.  
  953.         /**
  954.          * Removes the specified focus listener so it no longer receives focus 
  955.          * events from this component.
  956.          *
  957.          * @param l the focus listener
  958.          */
  959.         public void removeFocusListener(FocusListener l) {
  960.             JDialog.this.removeFocusListener(l);
  961.         }
  962.     } // inner class AccessibleJDialog
  963. }
  964.